import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
	public static long getDivisorsSum(long n) {
		final long originalN = n;
		long sum = 0L;
		long i = 2L, count;
		long divisor = 0L;
		
		while(n != 1) {
			count = 0L;
			while(n % i == 0) {
				n /= i;
				count++;

				sum += n;
				
				divisor = (long)Math.pow(i, count);
				sum += divisor;
			}			
			i++;
		}
		sum -= divisor;
		return sum;
	}
	public static boolean isPerfectNumber(long n, long divisorsSum) {
		if(divisorsSum != 1)
			if(divisorsSum == n)
				return true;
		return false;
	}
	public static String result(boolean isPerfectNumber) {
		if(isPerfectNumber)
			return "perfect";
		return "nonperfect";
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder output;
		String input;
		int cases;
		long n;
		
		while((input = br.readLine()) != null) {
			cases = Integer.parseInt(input);
			for(int c = 0; c < cases; c++) {
				input = br.readLine();
				n = Long.parseLong(input);
				
				output = new StringBuilder(result(isPerfectNumber(n, getDivisorsSum(n))));
				
				System.out.println(output);
			}
		}
	}
}